. If you'd like to know how to set up a project using it, click here.
This example is written in a way that it is meant to follow: AspectJ Example 3 and AspectJ Example 4. I specifically leave out details unchanged from those examples.
Now we'll introduce selecting pointcuts augmented by annotations. Begin by reviewing the following Java files and the expected output. Based on all of that information, your assignment is to describe what is happening and try to guess how it is happening. Note that the code provided here is somewhat stripped down to reduce what you have to look at. Later, we provide the full source in the Explained section.
Main.java
publicclass Main {publicstaticvoid main(String args[]){
Address a = new Address();
a.setIgnoredField("Ignored");
Dao.save(a);
a.setZip("75001");
Dao.save(a);}}
Dao.java
publicclass Dao {publicstaticvoid save(Object o){if(o != null){System.out.printf("Saving: %s\n", o.getClass());}}}
The Output
Not saving: class annotation.Address, it is unchanged
Saving: class annotation.Address
publicclass Address implementsSerializable{privateString addressLine1;privateString addressLine2;privateString city;privateString state;privateString zip;
@IgnoreField("Example of a field we ignore")privateString ignoredField;publicString getIgnoredField(){return ignoredField;}
AspectJ Annotation: Experience
Here is the full source for this example:This example is written in a way that it is meant to follow: AspectJ Example 3 and AspectJ Example 4. I specifically leave out details unchanged from those examples.
Now we'll introduce selecting pointcuts augmented by annotations. Begin by reviewing the following Java files and the expected output. Based on all of that information, your assignment is to describe what is happening and try to guess how it is happening. Note that the code provided here is somewhat stripped down to reduce what you have to look at. Later, we provide the full source in the Explained section.
Main.java
Dao.java
The Output
IgnoreField.java - the annotation
FieldSetAspect.java
<--Back Next-->